Skip to content

Update Tree Traversal C#. #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2018
Merged

Update Tree Traversal C#. #209

merged 2 commits into from
Jul 4, 2018

Conversation

june128
Copy link
Member

@june128 june128 commented Jul 3, 2018

Restructure code by removing the Node class. Remove CreateAllChildren method and make the constructor do it instead.

This is applying the changes suggested @Gustorn in #137 in discussion with @xam4lor .
The PR also removes the CreateAllChildren method and just makes the constructor recursive and do the creation.

… method and make the constructor do it instead.
@june128 june128 added the Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.) label Jul 3, 2018
Copy link
Contributor

@zsparal zsparal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the one nitpick this looks good

Node temp;
var stack = new Stack<Tree>();
stack.Push(this);
Tree temp;

while (stack.Count != 0)
{
Console.WriteLine(stack.Peek().Id);
temp = stack.Pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just do Tree temp = stack.Pop() instead of the separate declaration/initialization

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. :)

@zsparal zsparal merged commit 6d02784 into algorithm-archivists:master Jul 4, 2018
@june128 june128 deleted the updateTreeTraversalPR branch July 4, 2018 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants